<?php
error_reporting(0);
require_once("includes/pagetop.php");

if(!isset($_SESSION['Allyfolio_User_ID']) || $_SESSION['Allyfolio_User_ID']==0)
{
    redirect("index.php");
}

$patharr=explode("/",$_SERVER["REQUEST_URI"]);

$lastvars=end($patharr);

$afterWampToProjectRootPath=str_replace($lastvars,"",$_SERVER["REQUEST_URI"]);
if(!(isset($_REQUEST['t']) && trim($_REQUEST['t'])!=''))
{
    redirect("home.php");
}

$dnauserqry="select * from af_users where Allyfolio_User_ID=:afuserid and Profile_Status=0 ";
$condition[":afuserid"]=$_REQUEST['t'];
$dnauserinfo=$pdodbobj->fetch_array($pdodbobj->query($dnauserqry,$condition));

if(count($dnauserinfo)==0)
{
    redirect($_SERVER["HTTP_REFERER"]);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>AllyFolio | DNA </title>

<link href="css/style.css" rel="stylesheet" type="text/css" media="all"  />

<link rel="stylesheet" href="alertify/themes/alertify.core.css" />
<link rel="stylesheet" href="alertify/themes/alertify.default.css" id="toggleCSS" />
<script src="alertify/lib/alertify.min.js"></script>	
<script src="js/jquery1.10.2.min.js"></script>
<script src="js/modernizr.custom.56223.js"></script>



<script src="js/jquery.placeholder.js"></script>

<style type="text/css">

	.logo{ margin-top:10px;}

	.log_button{

	

	height:auto;

	margin:6px 0;

	overflow:hidden;

	float:left;

	margin-top:10px;

	

	}

	.new tr td{ vertical-align:top}

	

	textarea select{ border:1px solid #ccc}

	input textarea select{ border:1px solid #999}

	

</style>

</head>



<body>



	<div id="main_wrapper">

    <!--=================Header Start=======================-->

	<div class="wrapper row1">
    
    <?php
    require_once("includes/dnaheader.php");
    
    ?>

    <div class="clearfix"></div>  

    </div>

    <div class="clearfix"></div>

    <!--=================Header end=======================-->

    <!--=================Body Contain Start=======================-->

    <div class="wrapper">

      <div class="header">

        <?php include_once("dna_top.php"); ?>
        <style>
        	.dna-profile-hidden{
				display: none;
			}
		</style>

		<div class="dna_form">
			<form id="dna_profile_form" name="dna_profile_form">
				<input type="hidden" name="dna_purpose" id="dna_purpose" value="" />
				<table width="100%" border="0" cellspacing="10px" cellpadding="10px" class="new" style="font-size:16px; font-weight:bold;border-collapse:separate !important;">
					<tr valign="top">
						<td valign="top">
						<?php
							if($dnauserinfo[0]["User_ID"]==$_SESSION['Allyfolio_User_ID'])
							{
						?>
							<textarea id="Notebook" name="Notebook" rows="6" cols="90" class="dna-profile-hidden"><?php echo $dnauserinfo[0]["Notebook"]; ?></textarea>
						<?php
							}
						?>	
							<span id="Notebook_span"><?php if($dnauserinfo[0]["Notebook"]!=""){ echo $dnauserinfo[0]["Notebook"];} else { echo "-"; } ?></span>
						</td>
					</tr>
					<tr valign="top">
						<td valign="top">
					<?php
						if($dnauserinfo[0]["User_ID"]==$_SESSION['Allyfolio_User_ID'])
						{
					?>
							<a href="javascript:void(0);" onclick="return displaySave('notebook');"><span class="dna_edit" id="notebook_edit_span" >Edit</span></a>
							<a href="javascript:void(0);" onclick="return hideSave('notebook');"><span class="dna_edit dna-profile-hidden" id="notebook_cancel_span" >Cancel</span></a>&nbsp;&nbsp;
							<a href="javascript:void(0);" onclick="return saveInfo('notebook');"><span class="dna_edit dna-profile-hidden" id="notebook_save_span" >Save</span></a>
							<script>
								function displaySave(fromWhere)
								{
									if(fromWhere=="notebook")
									{
										$("#Notebook_span").hide();
										$("#Notebook").show();
									}
									$("#"+fromWhere+"_edit_span").hide();
									$("#"+fromWhere+"_save_span").show();
									$("#"+fromWhere+"_cancel_span").show();
								}
								
								function hideSave(fromWhere)
								{
									if(fromWhere=="notebook")
									{
										$("#Notebook").hide();
										$("#Notebook_span").show();
									}
									
									$("#"+fromWhere+"_save_span").hide();
									$("#"+fromWhere+"_cancel_span").hide();
									$("#"+fromWhere+"_edit_span").show();
								}
								
								function updateSpan(fromWhere)
								{
									if(fromWhere=="notebook")
									{
										$("#Notebook_span").html($("#Notebook").val());
									}
									
									$("#"+fromWhere+"_save_span").hide();
									$("#"+fromWhere+"_cancel_span").hide();
									$("#"+fromWhere+"_edit_span").show();
								}
								
								function saveInfo(purpose)
								{
									$("#dna_purpose").val(purpose);
									formdata = false;
									if (window.FormData) {
										formdata = new FormData(document.getElementById("dna_profile_form"));
									}
									var xmlhttp;	
									if (window.XMLHttpRequest)
									{
										xmlhttp=new XMLHttpRequest();
									}
									else
									{
										xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
									}
									xmlhttp.onreadystatechange=function()
									{
										if (xmlhttp.readyState==4 && xmlhttp.status==200)
										{	
											//document.getElementById(purpose+"_image_loader_div").style.display="none";
											var res=xmlhttp.responseText;	
											resArr=res.split("|~|");
											if(resArr[0]=="SUCCESS")
											{
												updateSpan(purpose);
												hideSave(purpose);
											}
											else
											{
												alertify.alert(resArr[1]);
											}
										}
									}	
									xmlhttp.open("POST","ajax_dna_profile.php",true);
									xmlhttp.send(formdata);
								}
								</script>
					<?php
						}
					?>
						</td>
					</tr>
			  </table>				
			</form>
		</div>

<div class="clearfix"></div>

       </div>  

</div>

    </div>

    <div class="clearfix"></div>

    <!--=================Body Contain end=======================-->

    </div>
    
<?php
    require_once("includes/footer.php");
?>